package Z04FanXin.FX02CanFanXinClass;



import Z006ClassAndObject.CO006ChuanCan.Hero;

import java.util.LinkedList;

public class FanXinClass {}

class HeroStack {

        LinkedList<Hero> heros = new LinkedList<Hero>();

        public void push(Hero h){
            heros.addFirst(h);
        }

        public Hero pull(){
            return heros.removeLast();
        }

        public Hero peek(){
            return heros.getLast();
        }

    public static void main(String[] args) {
        HeroStack heroStack = new HeroStack();
        for (int i = 0 ;i < 5 ;i++){
            Hero h = new Hero("Hero name" + i);
            System.out.println("压入栈的英雄：" + i);
            heroStack.push(h);
        }
        for (int i = 0;i < 5 ;i++){
            Hero h = heroStack.pull();
            System.out.println("弹出英雄：" + i);
        }
    }

}